package com.mdp.lcode.service;

import java.util.concurrent.TimeUnit;

import com.mdp.lcode.entity.FormDefVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class FormFieldCacheService {
	
	@Autowired 
	RedisTemplate redisTemplate;
	
	String cachKey="form_def_fields";
	
	public void putFormFields(String formId, FormDefVo formFields) {
		redisTemplate.opsForHash().put(cachKey+"_"+formId, formId, formFields);
		redisTemplate.expire(cachKey+"_"+formId, 100, TimeUnit.DAYS);
	}
	
	public FormDefVo getFormFields(String formId) {
		return (FormDefVo) redisTemplate.opsForHash().get(cachKey+"_"+formId, formId);
	}

	
}
